package config

import (
	"github.com/spf13/viper"
	"log"
)

type Config struct {
	Mysql struct {
		User string
		Pass string
		Host string
		Port int
		Data string
	}
}

type Nacos struct {
	NamespaceId string
	IpAddr      string
	Port        int
	DataId      string
	Group       string
}

var Conf Nacos

func ViperInit() {
	viper.SetConfigFile("C:\\Users\\32992\\Desktop\\lss\\user_service\\basic\\config\\dev.yaml")
	err := viper.ReadInConfig()
	if err != nil {
		panic(err)
	} else {
		log.Println("配置文件读取成功")
	}

	err = viper.Unmarshal(&Conf)
	if err != nil {
		panic(err)
	} else {
		log.Println("配置文件解析成功")
	}
}
